Repository navigation
Resolve mallinfo2 at runtime; fix always-zero malloc arena counters in el8 builds - #918
Conversation
CI Test ResultsRun: #43267243603 | Commit:
Status Overview
Legend: ✅ passed | ❌ failed | ⚪ skipped | 🚫 cancelled Summary: Total: 32 | Passed: 32 | Failed: 0 Updated: 2026-11-12 17:38:23 UTC |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c65bb37f75
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
More details
The runtime lookup removes the build-header gate without introducing a direct mallinfo2 symbol dependency. Validation was limited to static review and a C++ syntax check; runtime compatibility and JFR behavior were not exercised.
🤖 Bits Code Review · Commit c65bb37
c65bb37 to
a873a90
Compare
There was a problem hiding this comment.
More details
The runtime lookup avoids a direct mallinfo2 symbol dependency, and the mirrored layout is pinned against newer glibc headers. Runtime compatibility and JFR integration were not exercised in this review.
🤖 Bits Code Review · Commit a873a90
Scan-Build Report
Bug Summary
Filter Results by FileReports
|
|||||||||||||||||||||||||||||||||||||||||||||||||
…ld headers (PROF-16350)
…add functional counter test (PROF-16350)
…llocation (PROF-16350)
929ca35 to
efb2a4e
Compare
There was a problem hiding this comment.
More details
Runtime symbol resolution avoids a GLIBC_2.33 link-time dependency while preserving unset counters when mallinfo2 is unavailable. The completed static review identified no actionable defect.
🤖 Bits Code Review · Commit efb2a4e
Review findings (static review of the diff)This review read the diff only. It did not build or run anything. Please verify each point before acting. Correctness and robustness
Efficiency
Tests
|
…n cells (PROF-16621)
…nconclusive ldd probes (PROF-16350)
…n statics (PROF-16350)
|
@zhengyu123 Thanks — verified each point against the code. Three were real and are fixed in 64a395a / 5133806; the rest I believe are covered by the code as written, with the reasoning below. Fixed:
Not changed, with reasoning:
The remaining mutation-adequacy note (sentinel comparisons in This review also caught a real bug I had introduced while fixing an earlier one (the first caching version used plain non-atomic statics — formally UB on concurrent flushes); fixed with acquire/release publication in 5133806. |
rkennke
left a comment
There was a problem hiding this comment.
Looks good to me, thank you!
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
ff9a60e
into
main
What does this PR do?:
Resolves
mallinfo2at runtime instead of gating the call on the glibc build headers.mallocInfo.cpplooks the symbol up withdlsym(RTLD_DEFAULT, "mallinfo2")and declares a ten-fieldsize_tmirror ofstruct mallinfo2;static_asserts pin the mirror to the real struct wherever the headers declare it. Themalloc_*arena counters are therefore populated in every release build whenever the runtime glibc providesmallinfo2(2.33+), and stay unset otherwise.The counter semantics are stated where they live:
updateMallocArenaStats()documents the glibcint_mallinfomeaning of each field (arenasumsav->system_memover all arenas;keepcostis the main arena's top chunk only), anddoc/reference/ProfilerMemoryRequirements.mdgains a "Malloc Arena Counters" section covering availability and the unset cases.Motivation:
PROF-16350: the
malloc_*arena counters are the base for planned glibc arena-blowup detection, but they were compiled out of shipped builds:mallinfo2()was gated on__GLIBC_MINOR__ >= 33at compile time, and the release libraries are built in the el8 image against glibc 2.28 headers — so every shippedmalloc_arena_bytes/malloc_in_use_byteswas 0. Adlsymstring lookup adds noGLIBC_2.33symbol-version reference, so the same binary picksmallinfo2up from any runtime glibc that has it, regardless of build headers.Alternatives rejected:
mallinfo()fallback: itsintfields truncate past 2 GiB. Counters that silently wrap are worse than unset counters.Additional Notes:
Agentic review ran over the full change set (sphinx, deep effort): 10 findings — 8 fixed, 2 dismissed. Every post-review delta was re-reviewed (sphinx, standard effort). Two LOW findings remain open, both latent test-quality items in the
lddversion probe ofMallocArenaCountersTest: a failed probe on a modern-glibc host would assert counters are 0 instead of skipping, and a three-component pre-release banner (2.38.9000) would misprint the version in assertion messages. The 2.33 gate outcome stays correct in both cases. Follow-up ticket on request.Human review — recommended, not required: no critical area from
doc/WorkTracking.mdis touched (no public API, security, schema, dependency, or signal-handler change; themallinfo2lookup runs on the JFR flush path only). Recommended for two reasons: shipped-artifact JFR behavior changes — themalloc_*counters go from always-0 to real values, which consumers of these counters should acknowledge — and the unset-not-zero fallback semantics plus the documented-contract placement are recorded decisions on PROF-16350 worth a second pair of eyes.How to test the change?:
ddprof-testMallocArenaCountersTest(new): non-zeromalloc_arena_bytes/malloc_in_use_bytesthrough the full JFR flush path on a runtime glibc ≥ 2.33; counters unset otherwise (musl, older glibc); sanitizer/replacement-allocator runs skip the non-zero oracle.ddprof-libmallocArenaStats_ut.cpp(reworked): glibc accounting-identity,hblkhd, andmalloc_trimpremise tests against the same runtime-resolved path; skips at runtime wheremallinfo2is absent.Evidence:
:ddprof-lib:gtestDebugand:ddprof-lib:gtestRelease_mallocArenaStats, glibc 2.35 host:ddprof-test:testDebug -Ptests=MallocArenaCountersTestmallinfo2declaration)GLIBC_2.17(objdump -T)929ca356fFor Datadog employees:
credentials of any kind, I've requested a security review (run the
dd:platform-security-reviewskill, or file a request via the PSEC review form).
bewairealso runs automatically on every PR.